<template>
  <cfDialog :dialogObj='dialogObj'>
    <div slot='content' v-loading='loading'>
       <el-form ref='form' :model='form' label-width='120px' size='small' label-position='right'>
        <el-row>
          <el-col :span="24">
            <el-form-item label="任务编号：">{{ form.jobId }}</el-form-item>
            <el-form-item label="任务名称：">{{ form.jobName }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="任务分组：">{{ selectDictLabel(sysJobGroup, form.jobGroup) }}</el-form-item>
            <el-form-item label="创建时间：">{{ form.createTime }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="cron表达式：">{{ form.cronExpression }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="下次执行时间：">{{ parseTime(form.nextValidTime) }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="调用目标方法：">{{ form.invokeTarget }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="任务状态：">
              <div v-if="form.status == 0">正常</div>
              <div v-else-if="form.status == 1">失败</div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="是否并发：">
              <div v-if="form.concurrent == 0">允许</div>
              <div v-else-if="form.concurrent == 1">禁止</div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="执行策略：">
              <div v-if="form.misfirePolicy == 0">默认策略</div>
              <div v-else-if="form.misfirePolicy == 1">立即执行</div>
              <div v-else-if="form.misfirePolicy == 2">执行一次</div>
              <div v-else-if="form.misfirePolicy == 3">放弃执行</div>
            </el-form-item>
          </el-col>
        </el-row>
       </el-form>
    </div>
  </cfDialog>
</template>
<script>
import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus, exportJob } from "@/api/monitor/job";
export default {
  props: {
    dialogObj: {
      type: Object,
      default: ({
        visible: false,
        type: '',
        id: '',
        title: '',
        width: '520px'
      })
    }
  },
  data() {
    return {
      form: {},
      rules: { /**表单校验规则*/
        name: [{required: true, message: '名称不得为空', trigger: ['input', 'blur']}],
        sex: [{required: true, message: '性别不得为空', trigger: ['change']}]
      },
      optionsList: [],
      loading: false
    }
  },
  async mounted() {
    await this.getSysJobGroup();
    this.getDetailFn();
  },
  methods: {
    async getDetailFn() { /**获取弹窗详情*/
      this.loading = true;
      const res = await getJob(this.dialogObj.id);
      if(res.code == 200) {
        this.form = res.data;
      }
      setTimeout(()=>{
        this.loading = false;
      }, 500)
    }
  }
}
</script>